<?php
function checkLoginOrExit(UserModule $userMode){
    if($userMode->getLoginId()==null){
        header("Location:".WebRouter::init()->getPage("user","index"));
        exit();
    }
    $userInfo=$userMode->getLoginInfo();
    if($userInfo['type']!='admin'){
        $url=WebRouter::init()->getAbsolute("");
        View::displayAsTips($url,"抱歉,您不是管理员");
        exit();
    }
    return $userInfo;
}
class adminBase extends CodeCmsActivity {
    /** @var  UserModule */
    protected $user;
    function __construct() {
        parent::__construct();
        $this->user=UserModule::init();
        $userInfo=checkLoginOrExit($this->user);
        $this->cms->setUserName($userInfo['email']);
    }
}
